package day_2022_7_to_8.day48;

import java.util.Arrays;

/**
 * @author haomin
 * @date 2022/08/28 10:41
 **/
public class Day43_2_Num6160_AnswerQueries {
    class Solution1 {
        public int[] answerQueries(int[] nums, int[] queries) {
            Arrays.sort(nums);
            for(int i = 0; i < queries.length; ++i){
                int target = queries[i];
                int sum = 0, count = 0;
                for(int j = 0; j < nums.length && sum <= queries[i]; ++j){
                    sum += nums[j];
                    if(sum <= queries[i]) count ++;
                }
                queries[i] = count;
            }
            return queries;
        }
    }
}